using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.SharePoint;

namespace PS.WebParts.Rollup.GridViewWebPart
{
    public class BooleanColumn 
        : FormattedColumn
    {
        internal override string GetFormatedString(object container)
        {
            object value = DataBinder.GetPropertyValue(container, DataField);

            if (String.IsNullOrEmpty(value.ToString()))
            {
                return string.Empty;
            } 
            
            if (format.Split('/').Length < 2)
            {
                throw new SPException("invalid format string for boolean type");
            }

            if ("1" == value.ToString())
            {
                return format.Split('/')[0];
            }
            return format.Split('/')[1];
        }

        protected override DataControlField CreateField()
        {
            return new DateTimeColumn();
        }
    }
}
